package com.brillilab.starter.controller.crm;


import com.brillilab.common.entity.ResponseVo;
import com.brillilab.domain.vo.crm.CrmUsernamePasswordVo;
import com.brillilab.domain.vo.crm.CrmUsersInfoVo;
import com.brillilab.service.logic.crm.CrmUsersLogic;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/crm/user")
public class CrmUsersController {

    @Resource
    private CrmUsersLogic crmUsersLogic;

    /**
     * 登录
     * @param usernamePasswordVo
     * @return
     */
    @PostMapping("/login")
    public ResponseVo login(@RequestBody CrmUsernamePasswordVo usernamePasswordVo) {
        String userName = usernamePasswordVo.getUserName();
        String password = usernamePasswordVo.getPassword();
        Assert.isTrue(!StringUtils.isBlank(userName), "请输入用户名！");
        Assert.isTrue(!StringUtils.isBlank(password), "请输入密码！");
        CrmUsersInfoVo crmUsers = crmUsersLogic.userLogin(userName,password);
        return ResponseVo.success(crmUsers);
    }
}
